<%@page import="com.egame.manage.biz.server.gc.GameFileServiceImpl"%>
<%@page import="com.egame.manage.biz.server.ManageClient"%>
<%@page import="cn.egame.interfaces.gc.GameFileInfo"%>
<%@page import="com.egame.manage.biz.server.gc.GameServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.List"%>
<%@page import="cn.egame.interfaces.gc.TerminalInfo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/main.css"  />
<title>机型适配列表</title>
<%
	int gid = 0;
	if (request.getAttribute("gid") != null) {
		gid = (Integer) request.getAttribute("gid");
	}
	long fileid = 0;
	if (request.getAttribute("fileid") != null) {
		fileid = (Long) request.getAttribute("fileid");
	}
	
	List<String[]> brandMap = new ArrayList<String[]>();
	if(request.getAttribute("brandList") != null) {
		brandMap = (List<String[]>)request.getAttribute("brandList");	
	}
	int selectManufacture=-1;
	if((request.getAttribute("selectManufacturerId") != null)&&(Integer.parseInt(request.getAttribute("selectManufacturerId").toString())!=-1)) {
		selectManufacture =  Integer.parseInt(request.getAttribute("selectManufacturerId").toString());
	}
	int adapt=0;
	if((request.getAttribute("adapted") != null)) {
		adapt =  Integer.parseInt(request.getAttribute("adapted").toString());
	}
%>
<script type="text/javascript">
	function formSubmit(){
		document.getElementById("myform").submit();
	}
</script>
</head>
<body>
<form id="myform" action="<%=request.getContextPath() + "/tv/game/file/terminal/adapt/show.do" %>">
<input type="hidden" name="gid" value=<%=gid%>>
<input type="hidden" name="fileid" value=<%=fileid %>>
	<table cellpadding="0" cellspacing="0" class="table2">
		<tr>
			<td colspan=6>
			<select name="selectManufacturerId" id="selectManufacturerId">
	          	<option value="0">选择品牌</option>
          			<%  if(brandMap != null){
          					for(String[] brand:brandMap){     
          						if(brand.length==3){
          			%>          					
          					<option value="<%=brand[0] %>" <% if(brand[0].equals("" + selectManufacture)){ %>selected <%} %>><%=brand[1] %>-<%=brand[2] %></option>
          			<%	
          						}}
	          			}
          			%>
	         </select>
			<select name="adapted" id="adapted">
	          	<option value="0" <% if(adapt==0){ %>selected<%} %>>请选择</option>
          		<option value="2" <% if(adapt==2){ %>selected<%} %>>已适配</option>
          		<option value="1" <% if(adapt==1){ %>selected<%} %>>未适配</option>          		
	         </select>
	         <input type="submit" value="查询" class="btn3">
			</td>
		</tr>
				
		<tr>
			<th>序号</th>
			<th>品牌</th>
			<th>型号</th>
			<th>客户端UA</th>
			<th>分辨率</th>
			<th>操作</th>
		</tr>
		<%		
		if(request.getAttribute("pd") != null){
			PageData pd = (PageData)request.getAttribute("pd");
			List<TerminalInfo> list = (List<TerminalInfo>)pd.getContent();
			if(list != null){
				int i = 1;
				for(TerminalInfo bean: list){
					%>
		<tr>
			<td><%=i++ %></td>
			<td><%=bean.getTerminalName() %></td>
			<td><%=bean.getShortUA() %></td>
			<td><%=bean.getUACode() %></td>
			<td><%=bean.getScreenPx() %></td>
			<td>
			<%
				String para = "?gid=" + gid + "&fileid=" + fileid + "&terminalid=" + bean.getTerminalId();
				para += "&selectManufacturerId=" + selectManufacture + "&adapted=" + adapt;
				boolean adapted = GameFileServiceImpl.getInstance().hasAdapted(gid,bean.getTerminalId());
				if(adapted){
			%>
				<a href="<%=request.getContextPath() + "/tv/game/file/terminal/adapt/delete.do" + para %>">取消适配</a>
			<% }else{ %>
				<a href="<%=request.getContextPath() + "/tv/game/file/terminal/adapt.do" + para %>">适配</a>
			<% } %>
			</td>
		</tr>
		<%
				}
			}			
		}
		
	%>
	</table>
	<%@ include file="../page.in"%>
</form>
</body>
</html>